import { topMessage } from '@/components/TopMessage/data'
import { catchFn } from '@/libs/common'
import { imagePath } from '@/libs/file-utils'
import { updateUserInfo, userInfo } from '@/libs/user'
import { sendUserSign } from '@/pages/user/info/api'

const list = [
  {
    name: '个人信息',
    icon: imagePath('main/user/icon-info.png '),
    url: '/pages/user/info/index',
  },
  {
    name: '报告与测试',
    icon: imagePath('main/user/icon-archive.png '),
    url: '/pages/quiz/result/list/index',
  },
  {
    name: '消费记录',
    icon: imagePath('main/user/icon-bill.png '),
    url: '/pages/user/bill/index',
  },
  {
    name: '联系我们',
    icon: imagePath('main/user/icon-contact.png '),
    url: '/pages/user/feedback/index',
  },
  {
    name: '关于我们',
    icon: imagePath('main/user/icon-about.png '),
    url: '/pages/user/about/index',
  },
  // {
  //   name: '注销登录',
  //   icon: imagePath('main/user/icon-logout.png '),
  //   url: '',
  // },
]

export { list }

/**
 * 签到
 */
const sign = () => {
  if (userInfo.value?.signin) {
    topMessage.warn('今日已签到')

    return
  }

  catchFn(async () => {
    await sendUserSign()
    await updateUserInfo()

    topMessage.success('签到成功')
  })
}

export { sign }
